<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        // promise异常传透
        // (1) 当使用promise的then链式调用时, 可以在最后指定失败的回调, 
        // (2) 前面任何操作出了异常, 都会传到最后失败的回调中处理
        let p = new Promise((resolve, reject) => {
            resolve('OK');    
            //reject('error');
            //throw "错误";
        });

        // 调用then方法
        p.then(v => {
            console.log("aaaa");
        }).then(v => {
            console.log("bbbb");
            throw "no";
        }).then(v => {
            console.log("cccc");
        }).catch(r => {
            // 失败的回调
            console.log("Error", r);
        });
       
    </script>
</body>
</html>